package org.rsbot.script.methods;

import java.awt.Color;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.rsbot.script.wrappers.RSGroundItem;
import org.rsbot.script.wrappers.RSNPC;
import org.rsbot.script.wrappers.RSObject;
import org.rsbot.script.wrappers.RSPlayer;
import org.rsbot.script.wrappers.RSTile;

public class Methods
{
  protected Logger log = Logger.getLogger(getClass().getName());

  protected Random random = new Random();
  protected Skills skills;
  protected Settings settings;
  protected Magic magic;
  protected Bank bank;
  protected Players players;
  protected Store store;
  protected GrandExchange grandExchange;
  protected Hiscores hiscores;
  protected ClanChat clanChat;
  protected Camera camera;
  protected NPCs npcs;
  protected Game game;
  protected Combat combat;
  protected Interfaces interfaces;
  protected Mouse mouse;
  protected Keyboard keyboard;
  protected Menu menu;
  protected Tiles tiles;
  protected Objects objects;
  protected Walking walking;
  protected Calculations calc;
  protected Inventory inventory;
  protected Equipment equipment;
  protected GroundItems groundItems;
  protected Account account;
  protected Summoning summoning;
  protected Environment env;

  public void init(MethodContext paramMethodContext)
  {
    this.skills = paramMethodContext.skills;
    this.settings = paramMethodContext.settings;
    this.magic = paramMethodContext.magic;
    this.bank = paramMethodContext.bank;
    this.players = paramMethodContext.players;
    this.store = paramMethodContext.store;
    this.grandExchange = paramMethodContext.grandExchange;
    this.hiscores = paramMethodContext.hiscores;
    this.clanChat = paramMethodContext.clanChat;
    this.camera = paramMethodContext.camera;
    this.npcs = paramMethodContext.npcs;
    this.game = paramMethodContext.game;
    this.combat = paramMethodContext.combat;
    this.interfaces = paramMethodContext.interfaces;
    this.mouse = paramMethodContext.mouse;
    this.keyboard = paramMethodContext.keyboard;
    this.menu = paramMethodContext.menu;
    this.tiles = paramMethodContext.tiles;
    this.objects = paramMethodContext.objects;
    this.walking = paramMethodContext.walking;
    this.calc = paramMethodContext.calc;
    this.inventory = paramMethodContext.inventory;
    this.equipment = paramMethodContext.equipment;
    this.groundItems = paramMethodContext.groundItems;
    this.account = paramMethodContext.account;
    this.summoning = paramMethodContext.summoning;
    this.env = paramMethodContext.env;
  }

  public RSPlayer getMyPlayer()
  {
    return this.players.getMyPlayer();
  }

  public int random(int paramInt1, int paramInt2)
  {
    int i = Math.abs(paramInt2 - paramInt1);
    return Math.min(paramInt1, paramInt2) + (i == 0 ? 0 : this.random.nextInt(i));
  }

  public boolean verify(RSNPC paramRSNPC)
  {
    return paramRSNPC != null;
  }

  public boolean verify(RSObject paramRSObject)
  {
    return paramRSObject != null;
  }

  public boolean verify(RSTile paramRSTile)
  {
    return paramRSTile != null;
  }

  public boolean verify(RSGroundItem paramRSGroundItem)
  {
    return paramRSGroundItem != null;
  }

  public double random(double paramDouble1, double paramDouble2)
  {
    return Math.min(paramDouble1, paramDouble2) + this.random.nextDouble() * Math.abs(paramDouble2 - paramDouble1);
  }

  public void sleep(int paramInt1, int paramInt2)
  {
    sleep(random(paramInt1, paramInt2));
  }

  public void sleep(int paramInt)
  {
    try
    {
      long l1 = System.currentTimeMillis();
      Thread.sleep(paramInt);
      long l2;
      while (l1 + paramInt > (l2 = System.currentTimeMillis()))
        Thread.sleep(l1 + paramInt - l2);
    }
    catch (InterruptedException localInterruptedException) {
      localInterruptedException.printStackTrace();
    }
  }

  public void log(Object paramObject)
  {
    this.log.info(paramObject.toString());
  }

  public void log(Color paramColor, Object paramObject)
  {
    Object[] arrayOfObject = { paramColor };
    this.log.log(Level.INFO, paramObject.toString(), arrayOfObject);
  }
}